<?php

namespace App\Http\Controllers\CmsApi;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Redis;
use App\Lib\Response;
use App\Http\Controllers\BaseController;
use App\Http\Model\Hint;
use App\Http\Services\AngerbirdServices;


class InnerAngerbirdController extends BaseController
{
    protected $angerbirdService;

    public function __construct()
    {
        $this->angerbirdService = new AngerbirdServices();

    }

    /**
     * 愤怒的小鸟配置修改
     */
    public function angerbirdUpdateConfig(Request $request)
    {
        $key = $request->input('key');
        $val = $request->input('val');
        if(empty($key)) {
            Response::returnResult(Hint::PARAM_ERROR);
        }
        $data = $this->angerbirdService->angerbirdUpdateConfig($key, $val);

        Response::returnResult($data['code'], $data['data'], $data['msg']);
    }

    /**
     * 愤怒的小鸟新增商店
     */
    public function angerbirdAddShop(Request $request)
    {
        $giftId = (int) $request->input('gift_id', 0);
        $energyCoin = (int) $request->input('energy_coin', 0);
        $ifShow = (int) $request->input('if_show', 0);
        if(empty($giftId) || empty($energyCoin) || empty($ifShow)) {
            Response::returnResult(Hint::PARAM_ERROR);
        }
        $data = $this->angerbirdService->angerbirdAddShop($giftId, $energyCoin, $ifShow);

        Response::returnResult($data['code'], $data['data'], $data['msg']);
    }

    /**
     * 愤怒的小鸟修改商店
     */
    public function angerbirdUpdateShop(Request $request)
    {
        $shopId = (int) $request->input('shop_id', 0);
        $energyCoin = (int) $request->input('energy_coin', 0);
        $ifShow = (int) $request->input('if_show', 0);
        if(empty($shopId)) {
            Response::returnResult(Hint::PARAM_ERROR);
        }
        $data = $this->angerbirdService->angerbirdUpdateShop($shopId, $energyCoin, $ifShow);

        Response::returnResult($data['code'], $data['data'], $data['msg']);
    }

}